Skip to content

[PR] gate: fix upstream recorder leak causing real model gate deadlock (pipe inheritance) | gate: 修上游 recorder 泄漏导致真模型门禁卡死(管道继承) - #6671

Merged
ranxianglei merged 1 commit into
masterfrom
fix/gate-recorder-pipe-leak
Nov 14, 2026
Merged

ranxianglei merged 1 commit into
masterfrom
fix/gate-recorder-pipe-leak

Conversation

@ranxianglei

Copy link
Copy Markdown
Owner

现象

真模型 gate 跑 master 候选时,restart-lanes 段结束后整个 gate 卡死 3 小时:entrypoint 停在 do_wait 里等 | tee restart-lanes.log 的 EOF,而 EOF 永远不会来——Lane I/X 根本没机会跑(2026-11-14 实测,手动 kill 容器里的 recorder 进程后立即恢复)。

根因

scripts/gate/plugin-lanes.mjs 里 upstream recorder 以 stdio: ["ignore","ignore","inherit"] + detached: true 启动。stderr "inherit" 拿到的正是 entrypoint 那条 2>&1 | tee lane.log 管道的写端。当某条 lane 在自身 teardown 之前异常中止,detach 出去的 recorder 还活着、还握着这根管道 → tee 永远收不到 EOF → entrypoint 永远卡在 wait。

修复(scripts/gate/plugin-lanes.mjs,2 处)

  1. recorder 的 stderr 改写到每 lane 的 recorder.stderr.log(fs.openSync(..., "a"))——泄漏的 recorder 从此无害,这是根因修复;
  2. main() 的 per-agent catch 里对进行中的 recorder 补 SIGKILL(activeRec 跟踪)——lane 中止不再留孤儿进程。

验证:node --check 通过;gate 侧镜像内副本(restart-lanes.mjs / plugin-lanes.mjs)已同步同样修改并在真机跑通完整 plugin+restart 段。

The recorder was spawned with stdio ['ignore','ignore','inherit'] and
detached:true. When a lane aborted before its own teardown, the detached
recorder kept the inherited stderr open — which, in the entrypoint's
'| tee lane.log' pipeline, is the very pipe the entrypoint waits on.
The whole gate then sat in do_wait until someone killed the recorder
(observed 2026-11-14: master candidate run wedged 3h after the restart
lanes; I/X never ran).

- stderr goes to a per-lane recorder.stderr.log instead of the lane's
  inherited log pipe (a leaked recorder is now harmless).
- main()'s per-agent catch SIGKILLs the in-flight recorder so aborted
  lanes do not leave orphans behind.
@github-actions

Copy link
Copy Markdown
Contributor

📦 Built Package Artifact

Branch: fix/gate-recorder-pipe-leak (f31b710)

Latest build — install this exact version

npm install -g billion-context@0.0.9907-pr.6671.657e470

This exact version is immutable and reproducible. The rolling pr tag tracks the newest test build across all PRs.

Recent builds (commit → version)

commit version build
f31b710 billion-context@0.0.9907-pr.6671.657e470 build

Download artifact

  1. Download the artifact from the Actions run
  2. Extract the tarball and install:
tar xzf billion-context-pr6671.tgz
npm install -g package

Install instructions are refreshed on each push.

@ranxianglei ranxianglei changed the title gate: 修上游 recorder 泄漏导致真模型门禁卡死(管道继承) [PR] gate: fix upstream recorder leak causing real model gate deadlock (pipe inheritance) | gate: 修上游 recorder 泄漏导致真模型门禁卡死(管道继承) Nov 14, 2026
@ranxianglei
ranxianglei merged commit 9495c76 into master Nov 14, 2026
47 checks passed
@github-actions

Copy link
Copy Markdown
Contributor

📦 Merged Build Published

This merge to master was published as 0.0.1194-master.9495c76 (rolling master tag).

npm install -g billion-context@0.0.1194-master.9495c76  # this exact build
npm install -g billion-context@master  # always the newest merged build

npm view billion-context@master prints the current version at any time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant